using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
namespace CoreData
{
    public class Inventory_Detail
    {
        public long ID { get; set; }
        public long ProductID { get; set; }
        public long UnitID { get; set; }
        public int Quantity { get; set; }
        public int QuantityPercent { get; set; }
        public long InventoryID { get; set; }
        public long VoucherDetailID { get; set; }
        
        public string ProductNameExt { get; set; }
        public string UnitNameExt { get; set; }
        public string ProductCodeExt { get; set; }
       
        public Inventory_Detail()
        {
        }

        static Inventory_Detail DynamicCast<T>(object row_data, object row_header) where T : Inventory_Detail
        {
            // row_data : DataRow
            // row_header : DataColumnCollection
            Inventory_Detail ret = new Inventory_Detail();
            DataRow dt = (DataRow)row_data;

            foreach (DataColumn column in (DataColumnCollection)row_header)
            {
                switch (column.ColumnName)
                {
                    case "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "ProductID":
                        ret.ProductID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "UnitID":
                        ret.UnitID = ConvertObject.ToLong(dt[column]);
                        break;                   
                    case "QuantityPercent":
                        ret.QuantityPercent = ConvertObject.ToInt(dt[column]);
                        break;                  
                    case "InventoryID":
                        ret.InventoryID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "ProductName":
                        ret.ProductNameExt = ConvertObject.ToString(dt[column]);
                        break;
                    case "ProductCode":
                        ret.ProductCodeExt = ConvertObject.ToString(dt[column]);
                        break;
                    case "UnitName":
                        ret.UnitNameExt = ConvertObject.ToString(dt[column]);
                        break;
                    case "VoucherDetailID":
                        ret.VoucherDetailID = ConvertObject.ToInt(dt[column]);
                        break;      
                    default:
                        break;
                }
            }

            return ret;
        }

    }
}
